package com.gm.wholesale.module.setting.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.LinearLayout;

import androidx.annotation.Nullable;

import com.gm.wholesale.R;
import com.gm.wholesale.cacheData.CacheData;

public class GoodPriceControlView extends LinearLayout {

    public GoodPriceControlView(Context context) {
        super(context);
        init(context);
    }

    public GoodPriceControlView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    private void init(Context context) {
        View view1 = LayoutInflater.from(context).inflate(R.layout.view_price_switch, this);
        CheckBox checkBox = view1.findViewById(R.id.checkBox);
        checkBox.setChecked(CacheData.getShowPriceView());
        checkBox.setOnCheckedChangeListener((compoundButton, b) -> CacheData.saveShowPriceView(b));


        CheckBox checkBoxAutoInputPrice = view1.findViewById(R.id.checkBoxIsAutoInputPrice);
        checkBoxAutoInputPrice.setChecked(CacheData.getIsAutoInputPrice());
        checkBoxAutoInputPrice.setOnCheckedChangeListener((compoundButton, b) -> CacheData.saveIsAutoInputPrice(b));


    }
}
